package com.sky.handler;

import com.sky.exception.BusinessException;
import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result Exception(Exception ex){
        ex.printStackTrace();
        log.error("未知异常"+ex);

        return Result.error("系统紧急修复中");
    }
    @ExceptionHandler(BusinessException.class)
    public Result BusinessException(BusinessException ex){

        return Result.error(ex.getMessage());
    }
}
